<!DOCTYPE html>
<html data-layout-decorate="~{fragment/layout}">
<head>
<meta charset="UTF-8">
<title>点名</title>
<link rel="stylesheet" data-th-href="@{../static/bootstrap/css/bootstrap-theme.css}">
<link rel="stylesheet" th:href="@{../webjars/bootstrap-table/1.9.1-1/bootstrap-table.css}">
<link rel="stylesheet" th:href="@{../webjars/bootstrap-select/2.0.0-beta1/dist/css/bootstrap-select.css}">
<link data-th-href="@{../webjars/bootstrapvalidator/css/bootstrapValidator.css}"	rel="stylesheet" />
<script data-th-src="@{../webjars/knockout/knockout.js}" type="text/javascript"></script>
<script	data-th-src="@{../webjars/knockout-mapping/2.4.1/knockout.mapping.js}" type="text/javascript"></script>
<script type="text/javascript" 	th:src="@{../webjars/bootstrap-select/2.0.0-beta1/dist/js/bootstrap-select.js}"></script>
<script type="text/javascript" th:src="@{../webjars/bootstrap-select/2.0.0-beta1/dist/js/i18n/defaults-zh_CN.js}"></script>
<script	data-th-src="@{../webjars/bootstrapvalidator/js/bootstrapValidator.js}"></script>
<script data-th-src="@{../webjars/bootstrap-table/bootstrap-table.js}"></script>
<script	data-th-src="@{../webjars/bootstrap-table/locale/bootstrap-table-zh-CN.js}"></script>
<script data-th-src="@{../webjars/bootbox/4.4.0/bootbox.js}"></script>
</head>
<body>
<section layout:fragment="content">
		<div>
			<div class="input-group col-md-4 ">
				<span class="input-group-addon">教师：</span> <input type="text"
					class="form-control" th:value="${f.teacher}" readonly="readonly">
			</div>
			<div class="input-group col-md-4 ">
				<span class="input-group-addon">时间：</span> <input type="text"
					class="form-control" th:value="${f.time}" readonly="readonly">
			</div>
			<div class="input-group col-md-4 ">
				<span class="input-group-addon">课程：</span> <input type="text"
					class="form-control" th:value="${f.course}" readonly="readonly">
			</div>
			<div class="input-group col-md-4 ">
				<span class="input-group-addon">节次：</span> <input type="text"
					class="form-control" th:value="${f.jc}" readonly="readonly">
			</div>
			<button type="button" id="quan" class="btn btn-success" onclick="fun3()">全勤</button>
		</div>
			<table id="table1">
			</table>
	<script type="text/javascript">
	$('#table1').bootstrapTable({
		  url: 'page',
		  method:'POST',
          dataType:'json',
          contentType: "application/x-www-form-urlencoded",
          cache: false,
		  striped: true,
		  showRefresh:true,
		  columns: [{
		    field: 'name',
		    title: '姓名'
		  }, {
		    field: 'username',
		    title: '学号'
		  }, {
		    field: 'tbclass',
		    title: '班级'
		  }, {
			field: 'id',
		    title: '操作',
		    formatter: operateFormatter
		  }]
		})
		
		function operateFormatter(value, row, index) {
    return [
        "<div class='btn-group'>",
        "<button type='button' class='btn btn-success'onclick='fun(this.title);' title='"+value+"'>已到</button>",
        "<button type='button' class='btn btn-danger'onclick='fun1(this.title);' title='"+value+"'>未到</button>",
        "<button type='button' class='btn btn-warning'onclick='fun2(this.title);' title='"+value+"'>请假</button>",
        "</div>"
    ].join('');
}
	function fun(str) {
		$.ajax({  
		    url: 'isreach', 
		    type:"post",
		    data:{'id':str,'isReach':'已到'},
		    dataType: "json",  
		    success: function (data) {  
		    	bootbox.alert(data.msg);
		    	$("#table1").bootstrapTable('refresh', {url:'../callnames/page'});
			    },
			    error:function(result){
	            	  bootbox.alert("保存请求发送失败，请检查网络是否连通");
	              }
			});
	}
	function fun1(str) {
		$.ajax({  
		    url: 'isreach1', 
		    type:"post",
		    data:{'id':str,'isReach':'未到'},
		    dataType: "json",  
		    success: function (data) {  
		    	bootbox.alert(data.msg);
		    	$("#table1").bootstrapTable('refresh', {url:'../callnames/page'});
			    },
			    error:function(result){
	            	  bootbox.alert("保存请求发送失败，请检查网络是否连通");
	              }
			});
	}
	function fun2(str) {
		$.ajax({  
		    url: 'isreach1', 
		    type:"post",
		    data:{'id':str,'isReach':'请假'},
		    dataType: "json",  
		    success: function (data) {  
		    	bootbox.alert(data.msg);
		    	$("#table1").bootstrapTable('refresh', {url:'../callnames/page'});
			    },
			    error:function(result){
	            	  bootbox.alert("保存请求发送失败，请检查网络是否连通");
	              }
			});
	}
	function fun3() {
		$("#quan").prop('disabled', true);
		$.ajax({  
		    url: 'isreach2', 
		    type:"post",
		    dataType: "json",  
		    success: function (data) {  
		    	bootbox.alert(data.msg);
		    	$("#table1").bootstrapTable('refresh', {url:'../callnames/page'});
		    	$("#quan").prop('disabled', false);
			    },
			    error:function(result){
	            	  bootbox.alert("保存请求发送失败，请检查网络是否连通");
	            	  $("#quan").prop('disabled', false);
	              }
			});
	}
	</script>
</section>

</body>
</html>